﻿//--------------------------------------------------------------------------------------------------------------------------------------------------------
// <copyright file="FormsAuthenticationProvider.cs">
//     Copyright © 2010 Oli Francis
//     This source code is subject to the terms and conditions of the MIT license. A copy of the license can be found in the license.txt 
//     file at the root of this distribution. By using this source code in any fashion, you are agreeing to be bound by the terms of the MIT License. 
//     You must not remove this notice from the software.
// </copyright>
// <author>Oli</author>
//-------------------------------------------------------------------------------------------------------------------------------------------------------

namespace TeamBrain.Domain.Services.Security
{
    using System;
    using System.Web.Security;

    /// <summary>
    /// Wrapper around forms authentication
    /// </summary>
    public class FormsAuthenticationProvider : IAuthenticationProvider
    {
        /// <summary>
        /// Grants a session auth cookie.
        /// </summary>
        public void SetAuthCookie(int userId, bool persist)
        {
            FormsAuthentication.SetAuthCookie(userId.ToString(), persist);
        }

        /// <summary>
        /// Deletes the auth cookie.
        /// </summary>
        public void DeleteAuthCookie()
        {
            FormsAuthentication.SignOut();
        }
    }
}